/**
 * Class: Logger
 *
 * Purpose: 
 *
 * Created: Feb 1, 2010 @ 1:05:44 PM
 * @author Ken Scott
 */
package org.openfantasia.util;

import java.io.PrintStream;

public class Logger {

	private static boolean logging = true;

	private static boolean debugging = true;

	private static PrintStream stream = System.out;


	public static boolean isLogging() {
		return logging;
	}


	public static void setLogging(boolean logging) {
		Logger.logging = logging;
	}


	public static boolean isDebugging() {
		return debugging;
	}


	public static void setDebugging(boolean debugging) {
		Logger.debugging = debugging;
	}


	private static void print(String prefix, String string) {
		stream.println("[" + System.currentTimeMillis() + "] " + prefix + ": " + string);
	}


	public static void log(String string) {
		if (isLogging()) {
			print("LOG", string);
		}
	}


	public static void debug(String string) {
		if (isDebugging()) {
			print("DEBUG", string);
		}
	}

	
	public static void error(String string, Throwable t) {
		if (isLogging()) {
			print("ERROR", string);
			t.printStackTrace(stream);
			stream.println();
		}
	}
}
